package theOrbalEra.common.network;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;

import theOrbalEra.common.TheOrbalEra;
import theOrbalEra.common.util.OrbalUtils;
import theOrbalEra.common.util.DefultValue;
import theOrbalEra.common.util.idList.PacketId;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.network.packet.Packet250CustomPayload;

import com.google.common.io.ByteArrayDataInput;

import cpw.mods.fml.common.network.PacketDispatcher;

public class PacketDeEle extends PacketBase {

	public static PacketDeEle instance=new PacketDeEle();
	@Override
	void readClient(int id, ByteArrayDataInput data, Object[] extradata) {
		

	}

	@Override
	void readServer(int id, ByteArrayDataInput data, Object[] extradata) {
		int fire = data.readInt();
		int water = data.readInt();
		int earth = data.readInt();
		int wind = data.readInt();
		int time=data.readInt();
		int space=data.readInt();
		int unreal=data.readInt();
		
		EntityPlayer player=(EntityPlayer) extradata[0];
OrbalUtils.deStack(fire, water, earth,wind,time,space,unreal,player.username);

	}
	

	public static void deEle(int fire, int water, int earth, int wind, int time, int space, int unreal){

		ByteArrayOutputStream bos = new ByteArrayOutputStream(110);
		DataOutputStream dos = new DataOutputStream(bos);
		try {
			dos.writeInt(PacketId.DE_ELE);
			dos.writeInt(fire);
			dos.writeInt(water);
			dos.writeInt(earth);
			dos.writeInt(wind);
			dos.writeInt(time);
			dos.writeInt(space);
			dos.writeInt(unreal);
			
			
		} catch(Exception e) {
			e.printStackTrace();
		}
		
		Packet250CustomPayload pkt = new Packet250CustomPayload();
		pkt.channel = DefultValue.channel;
		pkt.data = bos.toByteArray();
		pkt.length = bos.size();
		pkt.isChunkDataPacket = false;
		PacketDispatcher.sendPacketToServer(pkt);
		
	}
	

}
